﻿// FIV Fast Image viewer
// http://code.google.com/p/fiv/
// 
// Copyright 2013, Ken Rentz.
//
// This is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this software; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301 USA, or see the FSF site: http://www.fsf.org.
// 
 

using System;
using System.Windows.Forms;

namespace FIV
{
	public partial class OptionsForm : Form
	{
		private readonly Options _TmpOptions;

		public OptionsForm()
		{
			_TmpOptions = Options.Instance;

			InitializeComponent();
			BindItems();
		}

		private void BindItems()
		{
			_FitToWindowCheckbox.DataBindings.Add("Checked", _TmpOptions, "FitToWindow");
			_MaintainAspectRatio.DataBindings.Add("Checked", _TmpOptions, "MaintainAspectRatio");
		}

		private void _OK_Click(object sender, EventArgs e)
		{
			_TmpOptions.Save();
			DialogResult = DialogResult.OK;
		}

		private void _Cancel_Click(object sender, EventArgs e)
		{
			_TmpOptions.Cancel();
			DialogResult = DialogResult.Cancel;
		}

		private void _ResetButton_Click(object sender, EventArgs e)
		{
			_TmpOptions.Reset();
		}

		private void _FitToWindowCheckbox_CheckedChanged(object sender, EventArgs e)
		{
			if (_FitToWindowCheckbox.Checked)
			{
				_MaintainAspectRatio.Enabled = true;			
			}
			else
			{
				_MaintainAspectRatio.Checked = false;
				_MaintainAspectRatio.Enabled = false;
			}
		}
	}
}
